using UnityEngine;
using System.Collections;

public class _Bg : MonoBehaviour {
	
	public Texture textura;
	public Vector2 size = new Vector2(100 , 30);
	
	public void Start()
	{
		gameObject.AddComponent("MeshRenderer");
		gameObject.AddComponent("MeshFilter");
		this.gameObject.transform.position = new Vector3 (transform.position.x * Menu.ns.x ,transform.position.y * Menu.ns.y, 3);
		
		Mesh mesh = Quad.Create(size.x * Menu.ns.x , size.y * Menu.ns.y);
		gameObject.GetComponent<MeshFilter>().mesh = mesh;
		gameObject.GetComponent<MeshRenderer>().material = (Material) Resources.Load("Outros/Material");
		gameObject.GetComponent<MeshRenderer>().material.mainTexture = textura;
	}
	
	public void Update()
	{
		transform.Translate(_Speed.speed , 0 , 0);
	
		if(this.gameObject.transform.position.x <= -90 * Menu.ns.x )
		{
			this.gameObject.transform.position = new Vector3(220 * Menu.ns.x , transform.position.y , 5);
		}
		
	}
	
}
